import { createElement, LinkHTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { commentAvatarDefaultProps } from './defaultProps';
import type { CommentAvatarOptions } from './type';

export interface CommentAvatarProps extends CommentAvatarOptions, LinkHTMLAttributes<HTMLLinkElement> {}

const CommentAvatar: FC<CommentAvatarProps> = (props) => {
  const { className, src, forwardedRef, ...commentAvatarProps } = props;

  return createElement(
    'a',
    { ref: forwardedRef, className: classNames('avatar', className), ...commentAvatarProps },
    createElement('img', { src }),
  );
};

CommentAvatar.displayName = 'CommentAvatar';
CommentAvatar.defaultProps = commentAvatarDefaultProps;

export default CommentAvatar;
